package cn.wizzer.app.crown.modules.models;

import cn.wizzer.framework.base.model.BaseModel;
import lombok.Data;
import org.nutz.dao.entity.annotation.*;
import org.nutz.dao.interceptor.annotation.PrevInsert;

import java.io.Serializable;
import java.util.Objects;

/**
 * 联赛赛果
 */
@Data
@Table("crown_league_result")
@TableIndexes({@Index(name = "sub_league_id_and_winner_and_version", fields = {"leagueId","winner","version"}, unique = true)})
public class CrownLeagueResult extends BaseModel implements Serializable {
    @Column
    @Name
    @Comment("ID")
    @ColDefine(type = ColType.VARCHAR, width = 32)
    @PrevInsert(els = {@EL("uuid()")})
    private String id;


    /**
     * 联赛表ID
     */
    @Column("league_id")
    @Comment("联赛表ID")
    @ColDefine(type = ColType.VARCHAR, width = 32)
    private String leagueId;


    /**
     * 获胜队
     */
    @Column
    @Comment("获胜队")
    @ColDefine(type = ColType.VARCHAR, width = 32)
    private String winner;



    /**
     * 版本号
     */
    @Column
    @Comment("版本号")
    private Integer version;

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        CrownLeagueResult that = (CrownLeagueResult) o;
        return Objects.equals(leagueId, that.leagueId) &&
                Objects.equals(winner, that.winner);
    }

    @Override
    public int hashCode() {
        return Objects.hash(winner);
    }
}
